package com.zmx.doctor.adapter;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.bumptech.glide.Glide;
import com.wang.adapters.adapter.BaseAdapterRvList;
import com.wang.adapters.base.BaseViewHolder;
import com.zmx.doctor.R;
import com.zmx.doctor.pojo.MeetingDoctor;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import de.hdodenhof.circleimageview.CircleImageView;

/**
 * 程序猿：胖胖祥
 * 时 间：2020/8/12  23:23
 * 功 能：
 */
public class MeetingDoctorAdapter extends BaseAdapterRvList<MeetingDoctorAdapter.ViewHolder, MeetingDoctor> {

    private List<MeetingDoctor> list;

    public MeetingDoctorAdapter(Activity activity, @Nullable List<MeetingDoctor> list) {
        super(activity, list);
        this.list = list;
    }

    @Override
    protected void onBindVH(ViewHolder holder, int listPosition, MeetingDoctor meetingDoctor) {

        if (list.size() == listPosition+1){

            holder.head.setVisibility(View.GONE);
            holder.add.setVisibility(View.VISIBLE);

        }else{

            holder.add.setVisibility(View.GONE);
            holder.head.setVisibility(View.VISIBLE);

        }

        Glide.with(mActivity).load(meetingDoctor.getAvatar()).into(holder.head);
    }

    @NonNull
    @Override
    protected ViewHolder onCreateVH(ViewGroup parent, LayoutInflater inflater) {

        MeetingDoctorAdapter.ViewHolder holder = new MeetingDoctorAdapter.ViewHolder(inflater.inflate(R.layout.doctor_meeting, parent, false));
        return holder;

    }

    static class ViewHolder extends BaseViewHolder {

        @BindView(R.id.head)
        CircleImageView head;

        @BindView(R.id.add)
        ImageView add;

        ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }

    }


}
